//
//  BaseTabBarViewController.m
//  LXStory
//
//  Created by xushichuan on 2018/7/26.
//  Copyright © 2018年 xushichuan. All rights reserved.
//

#import "BaseTabBarViewController.h"
#import "BaseNaviViewController.h"

@interface BaseTabBarViewController ()

@end

@implementation BaseTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor redColor];
    [self addChildViewControllers];
}

// 添加子控制器
- (void)addChildViewControllers
{
    // 设置首页控制器
    [self addChildrenViewController:[[NSClassFromString(@"LXMusicViewController") alloc]init]
                           andTitle:@"音乐"
                       andImageName:@"tab1_n"
               andSelectedImageName:@"tab1_p"];
    // 设置扩展控制器
    [self addChildrenViewController:[[NSClassFromString(@"LXPhotoViewController") alloc]init]
                           andTitle:@"照片"
                       andImageName:@"tab2_n"
               andSelectedImageName:@"tab2_p"];
    // 设置发现控制器
    //    XSCFindViewController
    [self addChildrenViewController:[[NSClassFromString(@"LXSweetViewController") alloc] init]
                           andTitle:@"蜜语"
                       andImageName:@"tab3_n"
               andSelectedImageName:@"tab3_p"];
    // 设置我的控制器
    [self addChildrenViewController:[[NSClassFromString(@"LXFeelingViewController") alloc]init]
                           andTitle:@"感言"
                       andImageName:@"tab4_n"
               andSelectedImageName:@"tab4_p"];
}

// 设置子控制器的tabbarItem的属性
- (void)addChildrenViewController:(UIViewController *)childVC andTitle:(NSString *)title andImageName:(NSString *)imageName andSelectedImageName:(NSString *)selectedImageName
{
    // 设置默认图片
    childVC.tabBarItem.image = [UIImage imageNamed:imageName];
    // 设置选中图片
    childVC.tabBarItem.selectedImage = [UIImage imageNamed:selectedImageName];
    // 设置标题
    childVC.title = title;
    childVC.view.backgroundColor = [UIColor whiteColor];
    // 添加导航控制器
    BaseNaviViewController *nav = [[BaseNaviViewController alloc] initWithRootViewController:childVC];
    // 添加到tabbar控制器
    [self addChildViewController:nav];
}


@end
